package com.sevenday.threadlimit;

import com.google.common.util.concurrent.RateLimiter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 
 * @类名: GuavaLimiter
 * @描述: 进行Guava的的限流使用
 * @作者: zfh
 * @邮箱：806970740@qq.com
 * @时间: 2017年9月3日 上午10:16:15
 */
public class GuavaLimiter {
	private  static  final Logger LOGGER = LoggerFactory.getLogger(GuavaLimiter.class);
	//表示每秒钟直接入2个请求的处理
	private final RateLimiter limiter = RateLimiter.create(2.0);
    public void process(List<Runnable> tasks,ExecutorService excutors){
        Thread thread = new Thread();
		for (Runnable task:tasks){
		    excutors.submit(task);
		    excutors.submit(thread);
		}
		limiter.acquire();
		//进行业务逻辑处理
	}
}
